package com.lims.landInfo.dao;

import static cn.org.rapid_framework.util.ObjectUtils.*;
import org.springframework.stereotype.Repository;

import javacommon.base.*;

import cn.org.rapid_framework.page.*;

import com.lims.landInfo.model.*;
import com.lims.landInfo.vo.query.*;

/**
 * @author zzh
 * @version 1.0
 * @since 1.0
 */@Repository @SuppressWarnings("unchecked")
public class InformationDao extends BaseHibernateDao<Information,java.lang.String>{
	
	public Class getEntityClass() {
		return Information.class;
	}
	
	public Page findPage(InformationQuery query) {
        //XsqlBuilder syntax,please see http://code.google.com/p/rapid-xsqlbuilder
        // [column]为字符串拼接, {column}为使用占位符. [column]为使用字符串拼接,如username='[username]',偷懒时可以使用字符串拼接 
        // [column] 为PageRequest的属性
		String sql = "select t from Information t where 1=1 "
			  	+ "/~ and t.sno = {sno} ~/"
			  	+ "/~ and t.landno = {landno} ~/"
			  	+ "/~ and t.landDeedNo = {landDeedNo} ~/"
			  	+ "/~ and t.houseCardNo = {houseCardNo} ~/"
			  	+ "/~ and t.houseOwner = {houseOwner} ~/"
			  	+ "/~ and t.corp = {corp} ~/"
			  	+ "/~ and t.east = {east} ~/"
			  	+ "/~ and t.south = {south} ~/"
			  	+ "/~ and t.west = {west} ~/"
			  	+ "/~ and t.north = {north} ~/"
			  	+ "/~ and t.landLevel = {landLevel} ~/"
			  	+ "/~ and t.sellAmount = {sellAmount} ~/"
			  	+ "/~ and t.sellExample = {sellExample} ~/"
			  	+ "/~ and t.marketPrice = {marketPrice} ~/"
			  	+ "/~ and t.marketExample = {marketExample} ~/"
			  	+ "/~ and t.describe = {describe} ~/"
				+ "/~ and t.landDate >= {landDateBegin} ~/"
				+ "/~ and t.landDate <= {landDateEnd} ~/"
				+ "/~ and t.createDate >= {createDateBegin} ~/"
				+ "/~ and t.createDate <= {createDateEnd} ~/"
				+ " order by t.sno asc ";

        //生成sql2的原因是为了不喜欢使用xsqlbuilder的同学，请修改生成器模板，删除本段的生成
        StringBuilder sql2 = new StringBuilder("select t from Information t where 1=1 ");
        if(isNotEmpty(query.getObjid())) {
            sql2.append(" and  t.objid = :objid ");
        }
        if(isNotEmpty(query.getSno())) {
            sql2.append(" and  t.sno = :sno ");
        }
        if(isNotEmpty(query.getLandno())) {
            sql2.append(" and  t.landno = :landno ");
        }
        if(isNotEmpty(query.getLandDeedNo())) {
            sql2.append(" and  t.landDeedNo = :landDeedNo ");
        }
        if(isNotEmpty(query.getHouseCardNo())) {
            sql2.append(" and  t.houseCardNo = :houseCardNo ");
        }
        if(isNotEmpty(query.getHouseOwner())) {
            sql2.append(" and  t.houseOwner = :houseOwner ");
        }
        if(isNotEmpty(query.getCorp())) {
            sql2.append(" and  t.corp = :corp ");
        }
        if(isNotEmpty(query.getEast())) {
            sql2.append(" and  t.east = :east ");
        }
        if(isNotEmpty(query.getSouth())) {
            sql2.append(" and  t.south = :south ");
        }
        if(isNotEmpty(query.getWest())) {
            sql2.append(" and  t.west = :west ");
        }
        if(isNotEmpty(query.getNorth())) {
            sql2.append(" and  t.north = :north ");
        }
        if(isNotEmpty(query.getLandLevel())) {
            sql2.append(" and  t.landLevel = :landLevel ");
        }
        if(isNotEmpty(query.getSellAmount())) {
            sql2.append(" and  t.sellAmount = :sellAmount ");
        }
        if(isNotEmpty(query.getSellExample())) {
            sql2.append(" and  t.sellExample = :sellExample ");
        }
        if(isNotEmpty(query.getMarketPrice())) {
            sql2.append(" and  t.marketPrice = :marketPrice ");
        }
        if(isNotEmpty(query.getMarketExample())) {
            sql2.append(" and  t.marketExample = :marketExample ");
        }
        if(isNotEmpty(query.getDescribe())) {
            sql2.append(" and  t.describe = :describe ");
        }
        if(isNotEmpty(query.getLandDateBegin())) {
            sql2.append(" and  t.landDate >= :landDateBegin ");
        }
        if(isNotEmpty(query.getLandDateEnd())) {
            sql2.append(" and  t.landDate <= :landDateEnd ");
        }
        if(isNotEmpty(query.getCreateDateBegin())) {
            sql2.append(" and  t.createDate >= :createDateBegin ");
        }
        if(isNotEmpty(query.getCreateDateEnd())) {
            sql2.append(" and  t.createDate <= :createDateEnd ");
        }
        if(isNotEmpty(query.getSortColumns())) {
            sql2.append(" order by :sortColumns ");
        }	
        
		return pageQuery(sql,query);
	}
	

}
